import 'package:lunar/lunar.dart';

const _lunarMonthLarge = ["", "正月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "腊月"];
const _lunarMonthNickName = ["", "孟春", "仲春", "季春", "孟夏", "仲夏", "季夏", "孟秋", "仲秋", "季秋", "孟冬", "仲冬", "季冬"];
const _lunarDayLarge = ["", "初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十"];
const _weekLarge = ["日", "一", "二", "三", "四", "五", "六"];

class DateUtil {

  static Lunar getNowLunar() {
    return Lunar.fromDate(DateTime.now());
  }

  static String getLargeWeek({int week = -1, DateTime? dateTime}) {
    return week == -1 ? _weekLarge[(dateTime ?? DateTime.now()).weekday % 7] : _weekLarge[week];
  }

  static String getNowMonthDay() {
    DateTime curDate = DateTime.now();
    return "${curDate.month}月${curDate.day}日";
  }

  static List<String> getNowDateLunarAndHoliday() {
    Lunar lunar = getNowLunar();
    Solar solar = lunar.getSolar();
    List<String> result = ["周${getLargeWeek(week: lunar.getWeek())}"];
    Holiday? holiday = HolidayUtil.getHolidayByYmd(solar.getYear(), solar.getMonth(), solar.getDay());
    if (holiday != null) result.add(holiday.getName());
    String jieQi = lunar.getJieQi();
    return result..add("${_lunarMonthLarge[lunar.getMonth()]}${_lunarDayLarge[lunar.getDay()]}")..add(jieQi.isEmpty ? _lunarMonthNickName[lunar.getMonth()] : jieQi);
  }

}